package com.itbaizhan.service;

import com.itbaizhan.dao.StudentDao;
import com.itbaizhan.domain.Student;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    //在使用applicationContext.xml中的SqlSessionTemplate时的写法
    @Autowired
    private SqlSessionTemplate session;
    public List<Student> findAll(){
        StudentDao studentDao = session.getMapper(StudentDao.class);
        return  studentDao.findAll();
    }
    public void add(Student student){
        StudentDao mapper = session.getMapper(StudentDao.class);
        mapper.add(student);
    }

}
